//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CBasicModel.h>
///	@path	~/src/graphics/xmodel/
///	@date	2007/11/16
///	@desc	Basic model class, holds only 'transform' , 'color' & 'opacity' attribute.

#pragma once

#include "xeres.h"

#include "graphics/IModel.h"
#include "graphics/IShaderVariable.h"
#include "graphics/IShaderAdapter.h"
#include "graphics/RenderManager.h"

namespace xeres {

	/*!
		\class	CBasicModel
		\brief	Basic model class.
	*/
	class CBasicModel : public IModel
	{
	public:

		/// \ctor
		CBasicModel( void );

		/// \dtor
		virtual ~CBasicModel( void );

		DECL_IOBJECT_CLASS( CBasicModel , IModel );

	public:

	//@ interface

		/// \impl
		virtual bool ConnectAttribute( const WString& name , RefWeak< IVar > var );

		/// \impl
		virtual bool DisconnectAttribute( const WString& name );

		/// \impl
		virtual void DisconnectAll( void );

		/// \impl
		virtual void Render( RenderContext& rc );

		/// \impl
		virtual void Batch( RenderManager& rm );

	// @ local

		/*! 
			\brief		Set model geometry, if replace is not set, exist model will be kept.
		*/
		bool SetGeometry( RefWeak<IGeometry> geometry , bool replace = false );

	private:

	//@ data

		// attribute list
		Ref< IVar >				m_transform;
		Ref< IVar >				m_color;
		Ref< IVar >				m_opacity;

		// connected shader variable
		Ref< IShaderVariable >	m_shaderTransform;
		Ref< IShaderVariable >	m_shaderColor;
		Ref< IShaderVariable >	m_shaderOpacity;

		// technique
		Ref< IShaderAdapter >	m_shader;

		// geometry
		Ref< IGeometry >		m_geometry;
	};

} // namespace xeres
